package com.topwater.topwater.service.impl;

import com.topwater.topwater.entity.BeHistory;
import com.topwater.topwater.dao.BeHistoryDao;
import com.topwater.topwater.service.BeHistoryService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;

/**
 * (BeHistory)表服务实现类
 *
 * @author 胡文 qq:986776
 * 自定义生成器制造
 */
@Service("beHistoryService")
public class BeHistoryServiceImpl implements BeHistoryService {
    @Resource
    private BeHistoryDao beHistoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BeHistory queryById(Integer id) {
        return this.beHistoryDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param beHistory 实例对象
     * @return 实例对象
     */
    @Override
    public BeHistory insert(BeHistory beHistory) {
        this.beHistoryDao.insert(beHistory);
        return beHistory;
    }

    @Override
    public BeHistory insertNotNull(BeHistory beHistory) {
        this.beHistoryDao.insertNotNull(beHistory);
        return beHistory;
    }

    /**
     * 修改数据
     *
     * @param beHistory 实例对象
     * @return 实例对象
     */
    @Override
    public BeHistory update(BeHistory beHistory) {
        this.beHistoryDao.update(beHistory);
        return this.queryById(beHistory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.beHistoryDao.deleteById(id) > 0;
    }

    /**
     * 字符串自动模糊查询
     **/
    public List<BeHistory> queryByLike(BeHistory beHistory) {
        return this.beHistoryDao.queryByLike(beHistory);
    }

    public List<BeHistory> queryByLike2(String str) {
        return this.beHistoryDao.queryByLike2(str);
    }

    /**
     * 多表连接查询
     */
    public List<Map> queryJoin(@Param("beHistory") BeHistory beHistory, @Param("tables") String... tables) {
        return this.beHistoryDao.queryJoin(beHistory, tables);
    }

    @Override
    public List<BeHistory> selectALl(BeHistory beHistory) {
        return this.beHistoryDao.selectALl(beHistory);
    }
}
